﻿
using Dm.util;
using SqlSugar;

namespace DataCollection.Core.Models
{
    /// <summary>
    /// 
    ///</summary>
    [SugarTable("c_template")]
    public class TemplateModel
    {
        #region 属性
        /// <summary>
        /// 备  注:模板编号
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "number", IsPrimaryKey = true)]
        public long Number { get; set; }

        /// <summary>
        /// 备  注:管道位置
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "pipe_position")]
        public string PipePosition { get; set; } = null!;

        /// <summary>
        /// 备  注:设计压力
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "design_pressure")]
        public double DesignPressure { get; set; }

        /// <summary>
        /// 备  注:阶段一压力
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "first_stage_pressure")]
        public double FirstStagePressure { get; set; }

        /// <summary>
        /// 备  注:阶段一持续时间
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "first_stage_time")]
        public int FirstStageTime { get; set; }

        /// <summary>
        /// 备  注:阶段一时间单位：小时、分钟
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "first_stage_time_unit")]
        public string FirstStageTimeUnit { get; set; } = null!;

        /// <summary>
        /// 备  注:阶段一判断方式 固定数值、浮动范围
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "first_stage_estimate_way")]
        public string FirstStageEstimateWay { get; set; } = null!;

        /// <summary>
        /// 备  注:阶段一判断数值
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "first_stage_estimate_value")]
        public double FirstStageEstimateValue { get; set; }

        /// <summary>
        /// 备  注:阶段二压力
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "second_stage_pressure")]
        public double SecondStagePressure { get; set; }

        /// <summary>
        /// 备  注:阶段二持续时间
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "second_stage_time")]
        public int SecondStageTime { get; set; }

        /// <summary>
        /// 备  注:阶段二时间单位
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "second_stage_time_unit")]
        public string SecondStageTimeUnit { get; set; } = null!;

        /// <summary>
        /// 备  注:阶段二判断方式
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "second_stage_estimate_way")]
        public string SecondStageEstimateWay { get; set; } = null!;

        /// <summary>
        /// 备  注:阶段二判断值
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "second_stage_estimate_value")]
        public double SecondStageEstimateValue { get; set; }

        /// <summary>
        /// 备  注:阶段三压力
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "third_stage_pressure")]
        public double ThirdStagePressure { get; set; }

        /// <summary>
        /// 备  注:阶段三持续时间
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "third_stage_time")]
        public int ThirdStageTime { get; set; }

        /// <summary>
        /// 备  注:阶段三时间单位
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "third_stage_time_unit")]
        public string ThirdStageTimeUnit { get; set; } = null!;

        /// <summary>
        /// 备  注:阶段三判断方式
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "third_stage_estimate_way")]
        public string ThirdStageEstimateWay { get; set; } = null!;

        /// <summary>
        /// 备  注:阶段三判断值
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "third_stage_estimate_value")]
        public double ThirdStageEstimateValue { get; set; }

        /// <summary>
        /// 备  注:强度阶段压力
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "intensity_stage_pressure")]
        public double IntensityStagePressure { get; set; }

        /// <summary>
        /// 备  注:强度阶段持续时间
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "intensity_stage_time")]
        public int IntensityStageTime { get; set; }

        /// <summary>
        /// 备  注:强度阶段时间单位
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "intensity_stage_time_unit")]
        public string IntensityStageTimeUnit { get; set; } = null!;

        /// <summary>
        /// 备  注:强度阶段判断方式 
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "intensity_stage_estimate_way")]
        public string IntensityStageEstimateWay { get; set; } = null!;

        /// <summary>
        /// 备  注:强度阶段判断值
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "intensity_stage_estimate_value")]
        public double IntensityStageEstimateValue { get; set; }

        /// <summary>
        /// 备  注:严密阶段压力
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "rigor_stage_pressure")]
        public double RigorStagePressure { get; set; }

        /// <summary>
        /// 备  注:严密阶段持续时间
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "rigor_stage_time")]
        public int RigorStageTime { get; set; }

        /// <summary>
        /// 备  注:严密阶段时间单位
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "rigor_stage_time_unit")]
        public string RigorStageTimeUnit { get; set; } = null!;

        /// <summary>
        /// 备  注:严密阶段判断方式
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "rigor_stage_estimate_way")]
        public string RigorStageEstimateWay { get; set; } = null!;

        /// <summary>
        /// 备  注:严密阶段判断值
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "rigor_stage_estimate_value")]
        public double RigorStageEstimateValue { get; set; }

        /// <summary>
        /// 备  注:误差范围
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "error_range")]
        public int ErrorRange { get; set; }

        /// <summary>
        /// 备  注:阶段数量
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "stage_count")]
        public int StageCount { get; set; }
        #endregion

        /// <summary>
        /// 添加
        /// </summary>
        /// <returns></returns>
        public int Add()
        {
            List<TemplateModel> list = new List<TemplateModel>();
            list.Add(this);
            int res = SqlSugarHelper.Insertable<TemplateModel>(list);
            return res;
        }

        /// <summary>
        /// 删除
        /// </summary>
        /// <returns></returns>
        public int Delete()
        {
            List<TemplateModel> list = new List<TemplateModel>();
            list.Add(this);
            int res = SqlSugarHelper.Deleteable<TemplateModel>(list);
            return res;
        }

        /// <summary>
        /// 更新
        /// </summary>
        /// <returns></returns>
        public int Update()
        {
            List<TemplateModel> list = new List<TemplateModel>();
            list.Add(this);
            int res = SqlSugarHelper.Updateable<TemplateModel>(list);
            return res;
        }

        /// <summary>
        /// 列表
        /// </summary>
        /// <param name="where"></param>
        /// <returns></returns>

        public static List<TemplateModel> List(Dictionary<string, object> where)
        {
            return SqlSugarHelper.Inquireable<TemplateModel>(where);
        }

        /// <summary>
        /// 分页列表
        /// </summary>
        /// <param name="where"></param>
        /// <returns></returns>

        public static List<TemplateModel> ListPage(Dictionary<string, object> where, int page, int pageSize, ref int totalCount)
        {
            return SqlSugarHelper.InquireableToPageList<TemplateModel>(where, page, pageSize, ref totalCount);
        }
    }
}
